#include<iostream>
#include<queue>
#include<cstring> 
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = N * 10;
int h[N], e[M], ne[M], idx;
int n;
int d[N];
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
int main()
{
	memset(h, -1, sizeof(h));
	cin >> n;
	int t = n;
	while (t--) {
		int a, b;
		cin >> a >> b;
		d[a]++;
		d[b]++;
		add(a, b);
		add(b, a);
	}
	queue<int>q;
	for (int i = 1; i <= n; i++) {
		if (d[i] == 1)q.push(i);
	}
	while (q.size()) {
		int t = q.front();
		q.pop();
		for (int i = h[t]; ~i; i = ne[i]) {
			int j = e[i];
			if (--d[j] == 1)q.push(j);
		}
	}
	for (int i = 1; i <= n; i++) {
		if (d[i] > 1) {
			cout << i << " ";
		}
	}
	return 0;
}
